<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>repair-detail-f</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
		<link rel="stylesheet" href="../css/bui.css">
		<script type="text/javascript" src="../script/api.js"></script>
		<script type="text/javascript" src="../script/zepto.js"></script>
		<script type="text/javascript" src="../script/doT.min.js"></script>
		<script type="text/javascript" src="../script/bui.js"></script>
		<style type="text/css">
			.solve-list{
				width:100%;
				height:100%;
			}
			.solve-list h3{
				font-weight: bold;
				font-size: .36rem;
			}
			.bui-list label{
				text-align-last: justify;
		    -moz-text-align-last: justify ;  //兼容firefox
		    text-align: justify;
		    text-justify: distribute-all-lines;  //兼容ie
		    display: block; //ie下需设为block
				width: 1.8rem;
			}
			.line{
				width: 100%;
				height: 2px;
				background: #eee;
			}
			.bui-list>[class*=bui-btn]{
				border-bottom: none;
			}
			input.bui-tag, input.bui-check{
				width: 1.8rem;
				border-radius: .3rem;
			}
			.img-list{
				padding-bottom: .2rem;
			}
			.img-list img{
				width: 100%;
				height: 100%;
			}
			.bui-nav.bui-fluid>[class*=bui-btn].bui-box-vertical{
				padding: .2rem;
				height: 2.6rem;
			}
			.span4{
			  color: #000;
			}
		</style>
	</head>
<body style="background-color:#fff;">
<div class="bui-page page-form" id="content"></div>
<script id="tpl" type="text/x-dot-template">
	<main class="solve-list">
		<h3 class="section-title">详情</h3>
		<ul class="bui-list">
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label" for="phonenumber">创建时间</label>：
				<div class="span1">
						{{=timestampToTime(it.createTime)}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label" for="password">创建人</label>：
				<div class="span1">
						{{=it.creator}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">设备编码</label>：
				<div class="span1">
					{{=it.deviceCode}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">企业名称</label>：
				<div class="span1">
					{{=it.enterpriseName}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">风机状态</label>：
				<div class="span4">
					{{=it.fanFault == 0 ? '正常' : '异常'}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">净化器状态</label>：
				<div class="span4">
					{{=it.purifierFault == 0 ? '正常' : '异常'}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">修改人</label>：
				<div class="span4">
					{{=it.modifier}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">修改时间</label>：
				<div class="span4">
					{{=timestampToTime(it.modifyTime)}}
				</div>
			</li>
			<li class="bui-btn bui-box clearactive">
				<label class="bui-label">备注</label>：
				<div class="span1">
					{{=it.remark}}
				</div>
			</li>
		</ul>
		<h3 class="section-title">附件</h3>
		<ul class="bui-nav shortcut-nav bui-fluid img-list">
			{{ var imgPath = it.imgPath; }}
			{{for(var p in imgPath){ }}
				<li class="bui-btn bui-box-vertical span4" tapmode onclick="openImageBrower('{{=imgPath}}','{{=p}}')"><img src="{{=static_url+imgPath[p]}}"/></li>
			{{ } }}
		</ul>
	</main>
</script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">

apiready = function(){

	var id = api.pageParam.id;

	getData(id);

}

//获取详情
function getData(id){
	var userData = $api.getStorage('mine');
	api.showProgress({
			title:'加载中',
			modal:false
	});
	ajaxRequest('post', {
			apiCode: 'REPAIR_DETAIL',
			userId: userData.userId,
			requestData: Number(id)
	}, function (ret, err) {
			api.hideProgress();
			if (ret.code == 200) {
				var enclosures = ret.result.enclosures || [];
				var imgPath = [];
				for(var i=0;i<enclosures.length;i++){
					imgPath.push(enclosures[i].path);
				}
				ret.result.imgPath = imgPath;
				var tpl = $('#tpl').html();
				var content = doT.template(tpl);
				$('#content').html(content(ret.result));
			} else {
				api.toast({
						msg: ret.message,
						location: 'middle'
				});
				return false;
			}
	});
}

function openImageBrower(arr, i) { //图片浏览器
		var str = arr.split(',');
		var data = [];
		for (var p in str) {
				data.push(static_url + str[p]);
		}
		//图片浏览器打开
		var obj = api.require('imageBrowser');
		obj.openImages({
				imageUrls: data,
				activeIndex: i
		});
}

function setHandleResult(status){
	if(!status){
		return '暂无';
	}else if(status == 1){
		return '设备损坏';
	}else if(status == 2){
		return '设备维修';
	}else if(status == 3){
		return '设备未供电';
	}
}

</script>
</body>
</html>
